package org.feng.manage.sys;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 日志切面
 *
 * @author feng
 */
@Slf4j
@Component
@Aspect
public class LogAspect {

    @Pointcut("@annotation(org.feng.manage.sys.CLog)")
    private void pointCut() {
    }

    @AfterReturning(value = "pointCut()")
    public void after(JoinPoint joinPoint) {
        // todo 执行后结果处理


        log.info("6666666666666");
    }

    @AfterThrowing(value = "pointCut()", throwing = "exception")
    public void afterThrowing(JoinPoint joinPoint, Exception exception) {
        // todo 执行时，发生异常
        log.error("6777777777777", exception);
    }
}
